package com.itboye.jinpuyiyuan.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.itboye.jinpuyiyuan.R;
import com.itboye.jinpuyiyuan.bean.BranchDepartmentBean;
import com.itboye.jinpuyiyuan.bean.RegisterHospitalBean;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/12/9 0009.
 */

public class RightAdapter extends BaseAdapter {

    private List<BranchDepartmentBean.DepartmentChild> list;
    private Context context;
    private LayoutInflater inflater;
    public  RightAdapter(Context context,List<BranchDepartmentBean.DepartmentChild> list){

        this.list=list;
        this.context=context;
        inflater=LayoutInflater.from(context);
    }
    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        RegisterHospitalChildHolder registerHospitalHolder;
        if (convertView==null){
            registerHospitalHolder=new RegisterHospitalChildHolder();
            convertView=inflater.inflate(R.layout.item_register_rightlist,parent,false);
            registerHospitalHolder.rightItemSelectTv=convertView.findViewById(R.id.rightItemSelectTv);

            convertView.setTag(registerHospitalHolder);
        }else {
            registerHospitalHolder= (RegisterHospitalChildHolder) convertView.getTag();
        }
        registerHospitalHolder.rightItemSelectTv.setText(list.get(position).getName());

        return convertView;
    }

    class RegisterHospitalChildHolder {
        TextView rightItemSelectTv;

    }
    public void addData(List<BranchDepartmentBean.DepartmentChild> list){
        this.list=list;
        this.notifyDataSetChanged();
    }

}
